# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=maplibre-gl-native
pkgver=1.6.0_git20220315
pkgrel=2
_commit="59fa32e96a8e24d439afc1bcba503e87852a4644"
pkgdesc="Open-source alternative to Mapbox GL Native"
url="https://maplibre.org/"
arch="all"
license="BSD-2-Clause"
makedepends="
	cmake
	icu-dev
	qt5-qtbase-dev
	rapidjson-dev
	"
source="https://dev.alpinelinux.org/archive/maplibre-gl-native/maplibre-gl-native-$pkgver.tar.gz"
options="!check" # No tests
subpackages="$pkgname-dev"
builddir="$srcdir/$pkgname"

provides="mapbox-gl-native=$pkgver-r$pkgrel"
replaces="mapbox-gl-native"

_disturl="dev.alpinelinux.org:/archive/$pkgname/"

snapshot() {
	clean
	deps
	mkdir -p "$srcdir" && cd "$srcdir"
	git clone https://github.com/maplibre/maplibre-gl-native -b $_commit --recursive
	tar czvf $SRCDEST/$pkgname-$pkgver.tar.gz maplibre-gl-native
	rsync --progress -La $SRCDEST/$pkgname-$pkgver.tar.gz $_disturl
}

prepare() {
	default_prepare

	# We prefer to build with our system version
	rm -r vendor/mapbox-base/extras/rapidjson
}

build() {
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=TRUE \
		-DMBGL_WITH_WERROR=OFF \
		-DMBGL_WITH_QT=ON \
		-DMBGL_WITH_QT_LIB_ONLY=ON \
		-DMBGL_WITH_QT_HEADLESS=OFF
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
fa69b83aefbebd85b2eb2cc859fad521c819fc4a4bda7583b89af69fd530b0aa5ec1b0a154745bffe98daaa3ccb0fc68e69d8d55ea539c142b4229ff32b02289  maplibre-gl-native-1.6.0_git20220315.tar.gz
"
